/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.cleber.dao;

import com.cleber.pojos.EnderecoCpf;
import com.cleber.util.HibernateUtil;
import org.hibernate.Session;

/**
 *
 * @author Santos
 */
public class EnderecoDao {

    private Session sessao;
    private EnderecoCpf endereco;

    public void addEndereco(EnderecoCpf e) {
        try {
            sessao = HibernateUtil.getSessionFactory().openSession();
            endereco = new EnderecoCpf();
            endereco.setCliente(e.getCliente());
            endereco.setRua(e.getRua());
            endereco.setNumero(e.getNumero());
            endereco.setComplemento(e.getComplemento());
            endereco.setBairro(e.getBairro());
            endereco.setCidade(e.getCidade());
            endereco.setEstado(e.getEstado());
            sessao.save(endereco);
            sessao.beginTransaction().commit();
        } catch (Exception ex) {
            ex.printStackTrace();
        } finally {
            sessao.close();
        }
    }
    
    public void removeEndereco(EnderecoCpf e){
        try {
            sessao = HibernateUtil.getSessionFactory().openSession();endereco = new EnderecoCpf();
        } catch (Exception ex) {
        }
    }
    
    
    
}
